package com.woniu.mapper;

import com.woniu.entity.Users;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from users where username=#{username} and pwd=#{pwd}  ")
    public Users selectUser(@Param("username") String username, @Param("pwd") String pwd);

    @Update("update users set money=money-#{price} where user_id =#{uid}")
    public void updateUser(@Param("uid") Integer uid,@Param("price") Double price);

    @Insert("insert into users(username,pwd,telphone,created_at,updated_at,power_id) values (#{username},#{pwd},#{telphone},#{created_at},#{updated_at},#{power_id})")
    public void insertUser(Users users);

    @Select("select * from users where username=#{username} ")
    public Users selectUserByName(String username);

    @Select("select * from users where power_id=#{power_id}")
    public List<Users> selectAllUsersByPowerId(Integer power_id);

    @Delete("delete from users where user_id=#{uid}")
    public void deleteUserById(Integer uid);

    @Select("select * from users where user_id = #{userId}")
    public Users selectUserByUid(int userId);

    @Update("update users set username=#{username} where user_id=#{uid}")
    public void updateUserName(@Param("username") String username,@Param("uid") Integer uid);

    @Update("update users set pwd=#{pwd} where user_id=#{uid}")
    public void updateUserPwd(@Param("pwd") String pwd,@Param("uid") Integer uid);

    @Update("update users set telphone=#{telphone} where user_id=#{uid}")
    public void updateUserTelphone(@Param("telphone") String telphone,@Param("uid") Integer uid);
}
